import type { NextApiRequest, NextApiResponse } from 'next';

export interface DownloadInfo {
  platform: string;
  icon: string;
  version: string;
  releaseTime: string;
  size: string;
  link: string;
  extraName: string;
}

export default function handler(req: NextApiRequest, res: NextApiResponse) {
  const response: DownloadInfo[] = [
    {
      platform: 'Windows 版本',
      icon: '/common/icon_win.png',
      version: `${process.env.WINDOWS_VERSION!}`,
      releaseTime: process.env.PUB_DATE!,
      size: process.env.WIN_SIZE!,
      link: `https://file.linksaas.pro/release/windows-x86_64/linksaas_${process.env.WINDOWS_VERSION!}_x64_zh-CN.msi`,
      extraName: '(x86_64)',
    },
    {
      platform: 'MacOS 版本',
      icon: '/common/icon_mac.png',
      version: `${process.env.MAC_VERSION!}`,
      releaseTime: process.env.PUB_DATE!,
      size: process.env.MAC_SIZE!,
      link: `https://file.linksaas.pro/release/darwin/${process.env.MAC_VERSION!}/linksaas.app.tar.gz`,
      extraName: '(universe)',
    },
    {
      platform: 'Linux 版本',
      icon: '/common/icon_linux.png',
      version: `${process.env.LINUX_VERSION!}`,
      releaseTime: process.env.PUB_DATE!,
      size: process.env.LINUX_SIZE!,
      link: `https://file.linksaas.pro/release/linux-x86_64/linksaas_${process.env.LINUX_VERSION!}_amd64.AppImage`,
      extraName: '(x86_64)',
    }
  ]
  res.status(200).json(response);
} 
